package com.whately.core.redis.distributelock;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.integration.redis.util.RedisLockRegistry;

@Configuration
public class RedisLockConfig {

    @Autowired
    private RedisConnectionFactory redisConnectionFactory;

    /****
     * redis lock registry
     */
    @Bean
    public RedisLockRegistry redisLockRegistry(){
        //15分钟-失效 ,即key的失效时间是15分钟（不释放锁的情况下）
        return new RedisLockRegistry(redisConnectionFactory,"whately-spring-redis-lock",15*60*1000L);
    }


}
